import { deepStrictEqual, strictEqual } from 'assert';
import { Mock } from 'lite-ts-mock';
import { TreePSD } from 'psd';

import { ButtonConverterBase } from './button-base';
import { Button } from './cc';

class Self extends ButtonConverterBase {
    protected get typer() {
        return 'ttt';
    }

    protected getName(layerName: string) {
        return layerName;
    }
}

describe('src/scene/service/converter/button-base.ts', () => {
    describe('.convert()', () => {
        it('ok', async () => {
            const mockTreePSD = new Mock<TreePSD>();
            const self = new Self(null as any, null as any, null as any, mockTreePSD.actual);

            mockTreePSD.expectReturn(
                r => r.export(),
                {
                    name: 'test',
                }
            );

            Reflect.set(self, 'createNode', (arg: any) => {
                deepStrictEqual(arg, {
                    name: 'test'
                });
                return 'node';
            });

            Reflect.set(self, 'appendUITransfrom', (arg: any) => {
                strictEqual(arg, 'node');
            });

            Reflect.set(self, 'appendComponent', (arg: any, arg1: any) => {
                strictEqual(arg, 'ttt');
                strictEqual(arg1, 'node');
            });

            mockTreePSD.expectReturn(
                r => r.children(),
                []
            );

            const res = await self.convert();
            strictEqual(res, 'node');
        });
    });
});